<!--
 * @Author: wangshuixin 2412658453@qq.com
 * @Date: 2025-04-03 14:46:16
 * @LastEditors: wangshuixin 2412658453@qq.com
 * @LastEditTime: 2025-06-22 16:41:18
 * @FilePath: \my-app\src\pages\index\index.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <view class="content">
    <!-- 简单使用默认导出 -->
    <WordExportButton :generator="testFileGenerator" filename="测试数据.docx" />
    
    <!-- 自定义内容导出 -->
    <WordExportButton 
      :generator="deliverConfirmFileGenerator1"
      filename="仲裁申请书.docx"
    >
      仲裁申请书
    </WordExportButton>
    <!-- <CustomKeyboard /> -->
  </view>
</template>

<script setup lang="ts">
// import CustomKeyboard from '../components/CustomKeyboard'
import { ref } from 'vue';
import WordExportButton from '../components/WordExportButton';
import { cmToDxa } from '@/utils/WordExporter';
import { deliverConfirmFileGenerator } from '@/utils/DeliverConfirmFile'
import { applyFileGenerator } from '@/utils/ApplyFile'

interface ApplyFileRequestType {
  startTime?: string, // 开始时间
  endTime?: string, // 结束时间
  typeName?: string, // 仲裁内容类型
  money?: string, // 请求仲裁金钱数量
}

// 导出“xx市劳动人事争议仲裁委员会送达确认书.docx”
const testFileGenerator = async (exporter) => {
  const config = {
    cityName: "南昌市",
    applicant: "张三",
    applicantAddress: "江西省南昌市xx区xx路xx号xx室",
    applicantPostalCode: "330033",
    applicantReceiver: "张二麻子",
    applicantPhone: "136132781293",
    applicantOtherContacts: "15193201124",
    respondent: "江西问界教育科技有限公司",
    respondentAddress: "江西省南昌市xx区xx路xx号xx室（此处填写申请人的有效送达地址）",
    respondentPostalCode: "330033",
    respondentAdmin: "阮子飏",
    respondentReceiver: "张满红",
    respondentPhone: "138132781293",
    respondentOtherContacts: "15793201124",
    applyTime: "2025年05月05日",
  }
  deliverConfirmFileGenerator(exporter, config)
}

const applyReqData = [
  {
    startTime: '2025年3月1日',
    endTime: '2025年3月31日',
    typeName: '工资',
    money: '8000',
  },
  {
    startTime: '2025年4月1日',
    endTime: '2025年4月30日',
    typeName: '工资',
    money: '8000',
  },
  {
    startTime: '2025年5月1日',
    endTime: '2025年5月7日',
    typeName: '工资',
    money: '1806.45',
  },
      
]

// 导出“仲裁申请书.docx”
const deliverConfirmFileGenerator1 = async (exporter) => {
  // 仲裁请求
  let applyReqList: TextRunObjectType[][] = []
  applyReqData?.forEach((applyReqItem: ApplyFileRequestType, index: number) => {
    const applyReqData: TextRunObjectType[] = [{
      text: `${index + 1}.`,
      style: {
        fontSize: 14,
        font: "仿宋",
      }
    }, {
      text: `请求裁决被申请人支付${applyReqItem?.startTime}至${applyReqItem?.endTime}的${applyReqItem?.typeName}合计${applyReqItem?.money}元。`,
      style: {
        fontSize: 14,
        font: "仿宋",
        underline: {
          type: "single",
          color: "#000000"
        }
      }
    }]
    applyReqList.push(applyReqData)
  })

  const config = {
    applicant: "张三",
    gender: "男",
    nation: "汉",
    birthday: "1991年06月30日", // 出生日期
    identityCard: "362229199106303017", // 身份证号
    registeredResidence: "江西省宜春市宜丰县",
    applicantPhone: "13087323943",
    applicantAddress: "江西省南昌市经开区金嘉名筑3期6栋",
    respondent: "江西问界教育科技有限公司",
    creditCode: "91360106MABW6QK822",
    respondentAddress: "江西省南昌市南昌高新技术产业开发区艾溪湖二路66号保利香槟国际花园H17楼店面114室",
    businessLocation: "江西省南昌市经济开发区广兰大道899号南昌交通学院科技园大楼303室",
    legalRepresentative: "阮子飏",
    respondentPosition: "执行董事、总经理",
    respondentPhone: "阮子飏18979316186",
    respondent_1: "江西智元创科技有限公司",
    respondentAddress_1: "江西省宜春市靖安县工业园香田新区墨轩湖大道2号",
    businessLocation_1: "江西省南昌市经开区南昌交通学院科技楼303室",
    legalRepresentative_1: "吴石",
    respondentPosition_1: "执行董事、总经理",
    respondentPhone_1: "吴帅东13767000090",
    applyReq: applyReqList,
  }
  applyFileGenerator(exporter, config)
}

const onExportError = (error) => {
  console.error(error);
  alert('导出失败，请查看控制台');
};
</script>

<style>
.content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
</style>
